/*
 * Copyright (C) 2010 EPRO
 */
package com.epro.dx.enable;

import android.content.Context;
import android.database.DataSetObserver;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;

/**
 * 前端适配器
 * @author cw55072
 * @version  [1.0, 2010-10-18]
 * @param <T>
 */
public class AdapterWrapper<T> extends ArrayAdapter<T>
{
    private ArrayAdapter<T> wrapped = null;
    
    public AdapterWrapper(Context context, int textViewResourceId, ArrayAdapter<T> wrapped)
    {
        super(context, textViewResourceId);
        this.wrapped = wrapped;
        wrapped.registerDataSetObserver(new DataSetObserver()
        {
            public void onChanged()
            {
                AdapterWrapper.this.notifyDataSetChanged();
            }
            
            public void onInvalidated()
            {
                AdapterWrapper.this.notifyDataSetInvalidated();
            }
        });
    }
    
    public T getItem(int position)
    {
        return (T)this.wrapped.getItem(position);
    }
    
    public int getCount()
    {
        return this.wrapped.getCount();
    }
    
    public int getViewTypeCount()
    {
        return this.wrapped.getViewTypeCount();
    }
    
    public int getItemViewType(int position)
    {
        return this.wrapped.getItemViewType(position);
    }
    
    public boolean areAllItemsEnabled()
    {
        return this.wrapped.areAllItemsEnabled();
    }
    
    public boolean isEnabled(int position)
    {
        return this.wrapped.isEnabled(position);
    }
    
    public View getView(int position, View convertView, ViewGroup parent)
    {
        return this.wrapped.getView(position, convertView, parent);
    }
    
    public long getItemId(int position)
    {
        return this.wrapped.getItemId(position);
    }
    
    protected ArrayAdapter<T> getWrappedAdapter()
    {
        return this.wrapped;
    }
}
